import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:seedfour/app/constants.dart';

class Tag extends StatelessWidget {
  final String text;
  final Color textColor;
  final double textSize;
  final Color? borderColor;
  final Color? backgroundColor;
  final EdgeInsetsGeometry? padding;
  final double? borderRadius;
  final Icon? leftIcon;
  final Icon? rightIcon;

  const Tag({
    super.key,
    required this.text,
    required this.textColor,
    required this.textSize,
    this.borderColor,
    this.backgroundColor,
    this.padding,
    this.borderRadius,
    this.leftIcon,
    this.rightIcon,
  });

  @override
  Widget build(BuildContext context) {
    return IntrinsicWidth(
      child: Container(
        padding: padding ??
            EdgeInsets.symmetric(horizontal: kSpaceSmall, vertical: kSpaceMini),
        decoration: BoxDecoration(
          color: backgroundColor ?? Colors.transparent,
          borderRadius: BorderRadius.circular(borderRadius ?? kRadiusMini),
          border: Border.all(
            color: borderColor ?? Colors.transparent,
            width: 0.5.w,
          ),
        ),
        child: Row(
          children: [
            if (leftIcon != null) ...[leftIcon!, SizedBox(width: kSpaceTiny)],
            Flexible(
              child: Text(
                text,
                maxLines: 1,
                overflow: TextOverflow.ellipsis,
                style: TextStyle(
                  color: textColor,
                  fontSize: textSize,
                  height: 1.2,
                ),
              ),
            ),
            if (rightIcon != null) ...[SizedBox(width: kSpaceTiny), rightIcon!],
          ],
        ),
      ),
    );
  }
}
